$(document).ready(function () {
    $("#error-info").css({color: "#FF3030", display: "none"});

    $("#userName").click(function () {
        $("#error-info").css({color: "#FF3030", display: "none"});
    });

    $("#password").click(function () {
        $("#error-info").css({color: "#FF3030", display: "none"});
    });

    $("#form-subject").click(function () {
        $('#login-form').bootstrapValidator('validate');
        var bootstrapValidator = $('#login-form').data('bootstrapValidator');
        //表单验证通过
        if (bootstrapValidator.isValid()) {
            var userName = $("#userName").val().trim();
            var password = $("#password").val().trim();
            $.post("loginController/checkUserInfo", {
                userName: userName,
                password: password
            }, function (data) {
                if (data.code == "1") {
                    $("#login-form").bootstrapValidator('resetForm', true);
                    $("#error-info").css({color: "#FF3030", display: "block"});
                } else {
                    window.location.href = "subject.html";
                }
            });
        }
    });
});


